package implementor;





import daoInterface.SellerInfoDao;
import dbhandeling.Crude;
import dto.SellerInfo;


public class SellerInfoImp extends Crude implements SellerInfoDao
{


	String className = new SellerInfo().getClass().getName();
	@Override
	public void add(SellerInfo cat) throws Exception {
		super.insert(cat);
		
	}

	@Override
	public void update(SellerInfo cat) throws Exception {
		System.out.println(cat.getSellerName());
		super.update(className, "sellerName", cat.getSellerName(), "autosellerId", cat.getautoSellerId()+"");
		super.update(className, "sellerPhone", cat.getSellerPhone(), "autosellerId", cat.getautoSellerId()+"");
		super.update(className, "sellerEmail", cat.getSellerEmail(), "autosellerId", cat.getautoSellerId()+"");
		super.update(className, "sellerAddress", cat.getSellerAddress(), "autosellerId", cat.getautoSellerId()+"");
		super.update(className, "status", cat.getStatus()+"", "autosellerId", cat.getautoSellerId()+"");
		
	}

	@Override
	public void delete(SellerInfo cat) {
		super.delete(className, "autosellerId", cat.getautoSellerId()+"");
		
	}

	@Override
	public SellerInfo[] retrieveArray( String conditionField,
			String conditionValue) throws Exception {
		Object[] cat= super.retreiveArrayOnCondition(className, conditionField, conditionValue);
		SellerInfo[]s=new SellerInfo[cat.length];
		
		for(int i=0;i<s.length;i++)
			s[i]=(SellerInfo) cat[i];
		return s;
	}

	@Override
	public SellerInfo[] retrieveAll() throws Exception {
		Object[] cat= super.retreiveAll(className);
		SellerInfo[] s=new SellerInfo[cat.length];
		
		for(int i=0;i<s.length;i++)
			s[i]=(SellerInfo) cat[i];
		return s;
	}

	@Override
	public SellerInfo retrieve( String conditionField,
			String conditionValue) throws Exception {
		SellerInfo s=(SellerInfo) super.retreive(className, conditionField, conditionValue);
		return s;
		
	}
	public int getAutoGenratedKey()
	{
		 int key=super.getAutoGenratedKey(className,"autosellerId") ;
		 return key;
	}
	
}
